package ejb.entities;

import java.io.Serializable;

import javax.persistence.*;

import ejb.dto.GiftListDTO;

import java.util.ArrayList;
import java.util.List;


/**
 * The persistent class for the giftlists database table.
 * 
 */
@Entity
@Table(name="giftlists")
@NamedQueries({
	@NamedQuery(name="Giftlist.findAll", query="SELECT g FROM Giftlist g"),
	@NamedQuery( name = "Giftlist.findByID", query = "SELECT g FROM Giftlist g WHERE g.idgiftlist LIKE :id"),
	@NamedQuery( name = "GiftList.findUserGiftList", query = "SELECT g FROM Giftlist g WHERE g.user.userid LIKE :idUser"),
	@NamedQuery( name = "GiftList.findGiftListOfUser", query = "SELECT g FROM Giftlist g WHERE g.user.userid LIKE :idUser AND g.name LIKE :nomeGf")
})

public class Giftlist implements Serializable 
{
	
	private static final long serialVersionUID = 1L;

	//attributi per generare query
	public static final String FIND_ALL = "Giftlist.findAll";
	public static final String FIND_BYID = "Giftlist.findByID";
	public static final String FINDUSERGF = "GiftList.findUserGiftList";
	public static final String FINDGFOFUSER = "GiftList.findGiftListOfUser";
	
	
	@Id
	@GeneratedValue(strategy=GenerationType.TABLE)
	private int idgiftlist;

	private String name;

	//bi-directional many-to-many association to Basicproduct
	@ManyToMany(mappedBy="giftlists")
	private List<Basicproduct> basicproducts;

	//bi-directional many-to-one association to User
	@ManyToOne
	@JoinColumn(name="userid")
	private User user;

	//bi-directional many-to-many association to Pack
	@ManyToMany(mappedBy="giftlists")
	private List<Pack> packs;
	
	public Giftlist()
	{
		this.packs = new ArrayList<Pack>();
		this.basicproducts = new ArrayList<Basicproduct>();
	}
	
	public Giftlist( GiftListDTO gfDTO ) 
	{
		this.name = gfDTO.getName();
		this.packs = new ArrayList<Pack>();
		this.basicproducts = new ArrayList<Basicproduct>();
	}

	public int getIdgiftlist() {
		return this.idgiftlist;
	}

	public void setIdgiftlist(int idgiftlist) {
		this.idgiftlist = idgiftlist;
	}

	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public List<Basicproduct> getBasicproducts() {
		return this.basicproducts;
	}

	public void setBasicproducts(List<Basicproduct> basicproducts) {
		this.basicproducts = basicproducts;
	}

	public User getUser() {
		return this.user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	public List<Pack> getPacks() {
		return this.packs;
	}

	public void setPacks(List<Pack> packs) {
		this.packs = packs;
	}

}